/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sunrise.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Andrea
 */
@Entity
@NamedQueries({
    @NamedQuery(name = WeatherAlert.findByRecipient, query = "SELECT w FROM WeatherAlert w WHERE w.recipient= :recipient and w.viewed=false"),
    @NamedQuery(name = WeatherAlert.findByEvent, query = "SELECT w FROM WeatherAlert w WHERE w.event= :event")
})

public class WeatherAlert implements Serializable {

    private static final long serialVersionUID = 1L;
    public static final String findByRecipient = "WeatherAlert.findByRecipient";
    public static final String findByEvent = "WeatherAlert.findByEvent";

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne
    private Event event;

    @ManyToOne
    private User recipient;

    @Temporal(TemporalType.DATE)
    Date alternativeDate;

    private boolean viewed;

    public WeatherAlert() {
        this.viewed = false;
    }

    public WeatherAlert(User recipient, Event event, Date alternativeDate) {
        this.recipient = recipient;
        this.event = event;
        this.viewed = false;
        this.alternativeDate = alternativeDate;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }

    public User getRecipient() {
        return recipient;
    }

    public void setRecipient(User recipient) {
        this.recipient = recipient;
    }

    public boolean isViewed() {
        return viewed;
    }

    public void setViewed(boolean viewed) {
        this.viewed = viewed;
    }

    public Date getAlternativeDate() {
        return alternativeDate;
    }

    public void setAlternativeDate(Date alternativeDate) {
        this.alternativeDate = alternativeDate;
    }
}
